import request from '@/utils/request'

const questionApi = {
    Question: '/api/question',
    Type: '/api/qtype',
    getAllType: '/api/qtype/all',

}

class Service {

    /**
    * @description GET 获取题目
    */
    static getQuestion(params: object) {
        return request({
            url: questionApi.Question,
            method: 'GET',
            json: true,
            params
        })
    }

    /**
    * @description GET 获取分类
    */
    static getClassify(params) {
        return request({
            url: questionApi.Type,
            method: 'GET',
            json: true,
            params,
        })
    }

    /**
    * @description GET 获取所有分类
    */
    static getClassifyAll() {
        return request({
            url: questionApi.getAllType,
            method: 'GET',
            json: true,
        })
    }
    /**
    * @description DELETE 删除题目
    */

    static delQuestion(id: Number) {
        return request({
            url: `${questionApi.Question}/${id}`,
            method: 'DELETE',
            json: true,
        })
    }

    static editType(data: object) {
        const { id } = data
        return request({
            url: `${questionApi.Type}/${id}`,
            method: 'put',
            json: true,
            data,
        })
    }

    static addType(data: object) {
        return request({
            url: questionApi.Type,
            method: 'post',
            json: true,
            data
        })
    }


}

export default Service
